// JavaScript Document
/*---------------------------------------------------------------ajax------------------------------------------------------------------------------*/
	function prompt_1(){if(window.XMLHttpRequest) {xmlHttp=new XMLHttpRequest();if(xmlHttp.overrideMimeType){xmlHttp.overrideMimeType("text/xml");}} 
	else if(window.ActiveXObject) {try {xmlHttp=new ActiveXObject("Msxml2.XMLHttp");}catch(e) {try {xmlHttp=new ActiveXobject("Microsoft.XMLHttp");}catch(e){}}}
    var url="public/Count/itemList.php?"+hret;xmlHttp.onreadystatechange=handle_f;xmlHttp.open("GET",url,false);xmlHttp.send(null);
	function handle_f(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){ajax_txt=xmlHttp.responseText;}else{alert("执行出现问题"+xmlHttp.statusText);}}}}

/*---------------------------------------------------------------行程里程统计-----------------------------------------------------------------------------*/

function HowLong(){
	var temp = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td style="border-bottom:1px solid #000;">查询指定车辆的行驶里程：</td></tr><tr><td><label id="selecttype">输入车牌</label>：<input type="text" id="querywords" name="querywords" value="豫A" style="width:180px; color:#666" /></td></tr><tr><td>开始时间：<input id="StartTime" type="text" name="StartTime" class="Wdate" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\'})" style="width:184px" /></td></tr><tr><td>结束时间：<input type="text" id="EndTime" name="EndTime" class="Wdate" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\'})" style="width:184px" /></td></tr><tr><td align="right"><input name="" type="button" class="btnbg" value="查询里程" style="width:70px;" onclick="QueryHowLong()"/></td></tr><tr><td align="left"><div id="HowLongNotice" style="color:red"></div></td></tr></table>';
	showMapMenu("行驶里程统计",temp);
}

function QueryHowLong(){
	//判断输入的条件是否为空
	var QueryWords = document.getElementById('querywords').value.toUpperCase();
	if(QueryWords == '' || QueryWords == '豫A'){
		$('#HowLongNotice').html('请输入车牌号，包括车辆或摩托车。');
		return false;
	}else{
		$('#HowLongNotice').html('');
	}
	//判断选择的时间是否符合要求
	var StartTime = document.getElementById('StartTime').value;
	var EndTime = document.getElementById('EndTime').value;
	if(StartTime == ''){
		$('#HowLongNotice').html('请选择开始时间。');
		return false;
	}else if(EndTime == ''){
		$('#HowLongNotice').html('请选择结束时间。');
		return false;
	}else{
		var sd = new Date(StartTime.replace(/-/g,"\/"));
		var ed = new Date(EndTime.replace(/-/g,"\/"));
		if(sd>ed){
			$('#HowLongNotice').html('开始时间不能大于结束时间。');
			return false;
		}else{
			//所有条件都符合清空所有提示信息
			$('#HowLongNotice').html('');
			$.ajax({
				type:"POST",
				url:"public/Count/itemList.php",
				data:'action=HowLong&plate='+QueryWords+'&starttime='+StartTime+'&endtime='+EndTime,
				success:function(data){
					//判断查询的车辆是否存在
					if(data == 'VehicleNone'){
						$('#HowLongNotice').html('您所查询的车辆不存在，请检查您的输入是否正确。');
						return false;
					}else if(data == 'LocNone'){
						$('#HowLongNotice').html('您查询的时间段内没有找到该车辆的行驶记录。');
						return false;
					}else{ //根据查到的坐标计算距离
						
						var HowLong = 0;
						var arr = data.split('|');
						for(var i=0;i<arr.length-2;i++){
							var a = arr[i].split(',');
							var b = arr[i+1].split(',');
							var time1 = Date.parse(new Date(a[2].replace(/-/g,"\/")));
							var time2 = Date.parse(new Date(b[2].replace(/-/g,"\/")));
							//判断如果两个点之间的时间差10秒以上就视为设备已经关机，不计算此两点间的距离
							if((time1-time2)>30000){
								HowLong +=0;
							}else{
								HowLong += GetShortDistance(parseFloat(a[0]), parseFloat(a[1]), parseFloat(b[0]), parseFloat(b[1]));
							}
						}
						$('#HowLongNotice').html('系统正在查找计算中，请稍后……');
						$('#HowLongNotice').html('<font color="#666666">您查询的车辆 <a style="color:#0CF;font-weight:bold">'+QueryWords+'</a> 该时间段内（在线时间）<br />共驶了大约 <a style="color:red;font-weight:bold">'+(Math.round(HowLong))/1000+'公里<\/a><\/font>');
					}
				}
			});
		}
	}
	
}

/*---------------------------------------------------------------路径分析-----------------------------------------------------------------------------*/

function SearchRoad(){
	var temp = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td>计算规则：<select id="pathRules" style="width:184px; color:#666"><option value="0">速度优先（默认）</option><option value="1">费用优先</option><option value="2">距离优先</option><option value="3">不走快速路</option><option value="9">多策略</option><option value="10">国道优先</option><option value="11">道省优先</option></select></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;从：<input value="郑州" id="driveLine_citynameS" type="text" style="width:184px" /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="driveLine_startname" type="text" style="width:184px" /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;到：<input value="郑州" id="driveLine_citynameE" type="text" style="width:184px" /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="driveLine_endname" type="text" style="width:184px" /></td></tr><tr><td align="right"><input name="" type="button" class="btnbg" value="分析路径" style="width:70px;" onclick="routeSearch()"/></td></tr><tr><td align="left"><div id="QueryRoadResult" style="color:red;"></div></td></tr></table>';
	showMapMenu("路径分析",temp);
}

function RouteSearch(){
	this.routeSType="rs";
	this.start_x = "";this.start_y = "";this.start_name = "";this.start_address = "";this.start_tel = "";this.start_pid = "";this.start_citycode = "";this.start_cityname = "";this.start_detailLink="";this.start_type="";
	this.end_x = "";this.end_y = "";this.end_name = "";this.end_address = "";this.end_tel = "";this.end_pid = "";this.end_citycode = "";	this.end_cityname = "";this.end_detailLink="";this.end_type="";
	this.route_segment;
}
var routeS = new RouteSearch();
function routeSearch(){
	
	document.getElementById("QueryRoadResult").innerHTML = '查询中……';
	
	routeS.start_cityname = document.getElementById('driveLine_citynameS').value;
	routeS.end_cityname = document.getElementById('driveLine_citynameE').value;
	routeS.start_name = document.getElementById('driveLine_startname').value;
	routeS.end_name = document.getElementById('driveLine_endname').value;
	var che = "";var che="";
	var i = 1 ;
	if(routeS.start_name=="请输入起点" || routeS.start_name==""){
		che += i + "．请输入起点\n" ;
		i = i + 1 ;
	}
	if(routeS.end_name=="" || routeS.end_name=="请输入终点"){
		che += i + "．请输入终点\n" ;
		i = i + 1 ;
	}
	if(routeS.start_cityname =="" ){
		che += i + "．请选择起点城市\n" ;
		i = i + 1 ;
	}
	if(routeS.end_cityname =="" ){
		che += i + "．请选择终点城市\n" ;
		i = i + 1 ;
	}
	if(i==1){
		routeS.routeSType = "rs";
		routeS_Startsearch(routeS.start_cityname,routeS.start_name);
	}else{
		alert(che);
	}
}
function routeS_Startsearch(k,c){
	mapObj.removeAllOverlays();
	var MSearch = new MPoiSearch();
	var opt = new MPoiSearchOptions();
	opt.recordsPerPage=1;
	opt.pageNum=1;
	MSearch.setCallbackFunction(routeStartSearch_CallBack);
	MSearch.poiSearchByKeywords(c,k,opt);
}
function routeStartSearch_CallBack(data){
	if(routeS.routeSType=="rs"){
		if(data.poilist.length==0){
			document.getElementById("QueryRoadResult").innerHTML = "起点未查找到任何结果!<br />建议：<br />1.请确保所有字词拼写正确。<br />2.尝试不同的关键字。<br />3.尝试更宽泛的关键字。";
		}else{
			routeS.start_x = data.poilist[0].x;
			routeS.start_y = data.poilist[0].y;
			routeS.start_name = data.poilist[0].name;
			routeS.start_address = data.poilist[0].address;
			routeS.start_tel = data.poilist[0].tel;
			routeS.start_type = data.poilist[0].type;
			routeS.start_pid = data.poilist[0].pguid;
			routeS.start_citycode = data.poilist[0].citycode;
		}
	}
	if(routeS.routeSType=="re"){
		if(data.poilist.length==0){
			document.getElementById("QueryRoadResult").innerHTML = "终点未查找到任何结果!<br />建议：<br />1.请确保所有字词拼写正确。<br />2.尝试不同的关键字。<br />3.尝试更宽泛的关键字。";
		}else{
			routeS.end_x = data.poilist[0].x;
			routeS.end_y = data.poilist[0].y;
			routeS.end_name = data.poilist[0].name;
			routeS.end_address = data.poilist[0].address;
			routeS.end_tel = data.poilist[0].tel;
			routeS.end_type = data.poilist[0].type;
			routeS.end_pid = data.poilist[0].pguid;
			routeS.end_citycode = data.poilist[0].citycode;
		}
	}
	routeS_Endsearch();
}
function routeS_Endsearch(){
	if(routeS.routeSType=="rs"){
		routeS.routeSType = "re";
		routeS_Startsearch(routeS.end_cityname,routeS.end_name);
	}else{
		route_search();
	}
}
function route_search(){
	if(routeS.start_x=="" || routeS.start_y=="" || routeS.end_x=="" || routeS.end_y=="" ){
		alert("起点和终点坐标不能为空!");
	}else{
		var pathRules = document.getElementById('pathRules').value;
		
		var startXY= new MLngLat(routeS.start_x,routeS.start_y);
		var endXY = new MLngLat(routeS.end_x,routeS.end_y);
		var mls = new MRouteSearch();
		var opt =new MRouteSearchOptions();
		opt.per=200//抽吸函数，表示在地图上画导航路径的关键点的个数。默认为150
		opt.routeType=Number(pathRules);//路径计算规则,0表示速度优先（默认）
		opt.name="";//避让区域名称
		var regionL="";//避让区域坐标
		mls.setCallbackFunction(routeSearch_CallBack);
		mls.routeSearchByTwoPoi(startXY,endXY,opt);
	}
}
function routeSearch_CallBack(data){
	var resultStr="";
	if(data.error_message != null){
		resultStr="查询异常！"+data.error_message;
	}else{
	switch(data.message){
	case 'ok':
		var route_count = data.count;
		if(route_count==0){
			resultStr="<div>&nbsp;&nbsp;&nbsp;&nbsp;未查找到任何结果!</div><div>&nbsp;&nbsp;&nbsp;&nbsp;建议：</div><div>&nbsp;&nbsp;&nbsp;&nbsp;1.请确保所有字词拼写正确。</div><div>&nbsp;&nbsp;&nbsp;&nbsp;2.尝试不同的关键字。</div><div>&nbsp;&nbsp;&nbsp;&nbsp;3.尝试更宽泛的关键字。</div>";
		}else{
			var route_text = "";var road_length = 0;
			var route_content = new Array();
			routeS.route_segment = new Array();
			for(var i=0;i<route_count;i++){
				routeS.route_segment[i] = data.segmengList[i].coor;//每一条路线的XY
				road_length += parseInt(data.segmengList[i].roadLength);//每一条路线的里程
				if(i==0){
					route_text += "<tr class=\"td_style\" id=\"tr_"+i+"\" onMouseover=\"this.style.backgroundColor='#efefef';\" onMouseout=\"this.style.backgroundColor='';\" onclick=\"driveLineDrawFoldline('"+i+"','"+route_count+"')\"><td align=\"center\">"+(i+1)+".</td><td width=\"177\">沿<strong>"+data.segmengList[i].roadName+"</strong>向<strong>"+data.segmengList[i].direction+"</strong><span class=\"gray\">行驶</span></td><td align=\"right\">"+Getdistance(data.segmengList[i].roadLength)+"</td><td>&nbsp;</td></tr>";
				}else{
					route_text += "<tr class=\"td_style\" id=\"tr_"+i+"\" onMouseover=\"this.style.backgroundColor='#efefef';\" onMouseout=\"this.style.backgroundColor='';\" onclick=\"driveLineDrawFoldline('"+i+"','"+route_count+"')\"><td align=\"center\">"+(i+1)+".</td><td width=\"177\">"+data.segmengList[i-1].action+"<span class=\"gray\">进入</span><strong>"+data.segmengList[i].roadName+"</strong>向<strong>"+data.segmengList[i].direction+"</strong><span class=\"gray\">行驶</span></td><td align=\"right\">"+Getdistance(data.segmengList[i].roadLength)+"</td><td>&nbsp;</td></tr>";
				}
			}
			route_content.push("<table width=\"309\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"inner_route_result\"><tr><td colspan=\"2\" style=\"background:#e1e1e1;\" width=\"216\">路线</td><td style=\" border-left:1px solid #fff; background:#e1e1e1;\">里程</td><td width=\"17\" style=\"background:#e1e1e1;\">&nbsp;</td> </tr><tr><td width=\"3\" align=\"center\"><img src=\"http://code.mapabc.com/images/start.gif\" /></td><td colspan=\"2\">起点："+routeS.start_name+"</td><td width=\"17\">&nbsp;</td></tr>"+route_text+"<tr><td align=\"center\"><img src=\"http://code.mapabc.com/images/end.gif\" /></td><td colspan=\"2\">终点："+routeS.end_name+"</td></tr><tr><td colspan=\"3\" align=\"right\">共："+Getdistance(road_length)+"</td></tr></table>");

			resultStr = route_content.join("");
			var allover = new Array();
			var arr = new Array();
			var poi_xy_r = data.coors.split(",");
			var poi_xy_rl = poi_xy_r.length-2
			for(var j=0;j<poi_xy_rl;j=j+2){
				arr.push(new MLngLat(poi_xy_r[j],poi_xy_r[j+1]));
			}
			var lineopt = new MLineOptions();
			lineopt.lineStyle.thickness=6;
			lineopt.lineStyle.color=0x005cb5;
			lineopt.lineStyle.alpha=0.8;
			var line = new MPolyline(arr,lineopt);
			lineopt.canShowTip=false;
			allover.push(line);
		/*起点终点*/
			var lineStyle=new MLineStyle();
			lineStyle.thickness=2;
			lineStyle.alpha=1;
			var fontStyle=new MFontStyle();
			fontStyle.name="Arial";
			fontStyle.size=12;
			fontStyle.color= 0xffffff;
			fontStyle.bold=true;
			var fontStyle1=new MFontStyle();
			fontStyle1.name="Arial";
			fontStyle1.size=13;
			fontStyle1.color= 0x000000;
			fontStyle1.bold=false;
			var fillStyle=new MFillStyle();
			fillStyle.color= 0xFFFFFF; //填充色
			fillStyle.alpha=1;
			var fillStyle1=new MFillStyle();
			fillStyle1.color= 0x005cb5; //填充色
			fillStyle1.alpha=1;
			var startmarkerOption = new MMarkerOptions();
			startmarkerOption.imageUrl ="http://code.mapabc.com/images/qd.png";
			var tipOption = new MTipOptions();
			tipOption.title=routeS.start_name;
			var tipC = TipContents(routeS.start_type,routeS.start_address,routeS.start_tel)
			tipOption.content=tipC;//tip内容
			tipOption.borderStyle=lineStyle;
			tipOption.titleFontStyle=fontStyle;
			tipOption.contentFontStyle=fontStyle1;
			tipOption.fillStyle=fillStyle;
			tipOption.titleFillStyle=fillStyle1;
			startmarkerOption.tipOption = tipOption;
			var start = new MLngLat(routeS.start_x,routeS.start_y);
			var startmarker= new MMarker(start,startmarkerOption);
			startmarker.id=routeS.start_pid;
			allover.push(startmarker);

			var endmarkerOption = new MMarkerOptions();
			endmarkerOption.imageUrl ="http://code.mapabc.com/images/zd.png";
			var tipOption = new MTipOptions();
			tipOption.title=routeS.end_name;
			var tipC = TipContents(routeS.end_type,routeS.end_address,routeS.end_tel)
			tipOption.content=tipC;//tip内容
			tipOption.borderStyle=lineStyle;
			tipOption.titleFontStyle=fontStyle;
			tipOption.contentFontStyle=fontStyle1;
			tipOption.fillStyle=fillStyle;
			tipOption.titleFillStyle=fillStyle1;
			endmarkerOption.tipOption = tipOption;
			var end = new MLngLat(routeS.end_x,routeS.end_y);
			var endmarker= new MMarker(end,endmarkerOption);
			endmarker.id=routeS.end_pid;
			allover.push(endmarker);
		/**/
			mapObj.addOverlays(allover,true);
		}
	break;
	case 'error':
		resultStr= "<div class=\"default\"><div class=\"default_title\">网络忙！请重新尝试！</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建议：</strong><br />如果您刷新页后仍无法显示结果，请过几分钟后再次尝试或者与我们的服务人员联系。<br />Email：service@mapabc.com <br />电话：400 810 0080</div></div></span>错误信息："+data.message+"</div>";
	break;
	default:
		resultStr= "<div class=\"default\"><div class=\"default_title\">对不起！网络繁忙！请稍后重新尝试！</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建议：</strong><br />如果您刷新页后仍无法显示结果，请过几分钟后再次尝试或者与我们的服务人员联系。<br />Email：service@mapabc.com <br />电话：400 810 0080</div></div></span>错误信息："+data.message+"</div>";
	}
	}
	document.getElementById("QueryRoadResult").style.height = '200px';
	document.getElementById("QueryRoadResult").style.overflowY = 'scroll';
	document.getElementById("QueryRoadResult").style.color = '#666666';
	document.getElementById("QueryRoadResult").innerHTML = resultStr;
}
function driveLineDrawFoldline(num,count){//画线路并控制左边列表.num为第几条线路,count全部线路数.
	var tr_id = "tr_"+num;
	for(var i=0;i<count;i++){
		var id = "tr_"+i;
		document.getElementById(id).style.background='';
		document.getElementById(id).onmouseout = function(){this.style.backgroundColor='';};
	}
	document.getElementById(tr_id).style.background='#efefef';
	document.getElementById(tr_id).onmouseout = function(){this.style.backgroundColor='#efefef';};
	var lineopt = new MLineOptions();
	lineopt.lineStyle.thickness=6;
	lineopt.lineStyle.color=0x33CC00;
	lineopt.lineStyle.alpha=0.8;
	var arr = new Array();
	var poi_xy  = routeS.route_segment[num].split(",");
	var l = poi_xy.length-1;
	for(var e=0;e<l;e=e+2){
		arr.push(new MLngLat(poi_xy[e],poi_xy[e+1]));
	}
	var line = new MPolyline(arr,lineopt);
	line.id="driveline";
	mapObj.addOverlay(line,true);
}
function TipContents(type,address,tel){
	if (type == "" || type == "undefined" || type == null || type == " undefined" || typeof type == "undefined") {
		type = "暂无";
	}
	if (address == "" || address == "undefined" || address == null || address == " undefined" || typeof address == "undefined") {
		address = "暂无";
	}
	if (tel == "" || tel == "undefined" || tel == null || tel == " undefined" || typeof address == "tel") {
		tel = "暂无";
	}
	var str ="<div style=\"padding:0 10px; line-height:180%; margin-top:-10px\"><br>地址：" + address + "<br>电话：" + tel + " <br>类型："+type+'</div>';
	return str;
}
function Getdistance(le){
	if(le<=1000){
		var s = le;
		return s+"米";
	}else{
		var s = Math.round(le/1000);
		return "约"+s+"公里";
	}
}

/*---------------------------------------------------------------区域分析-----------------------------------------------------------------------------*/
function count(){
	mapObj.addEventListener(mapObj,ADD_OVERLAY,addOverlayEvent);
	var str='<div>关键字：<select id="keyword"><option value="警察局" >警察局</option><option value="医院">医院</option><option value="酒店">酒店</option><option value="饭店">饭店</option><option value="歌厅">歌厅</option></select><br /><input type="button" onclick="mapObj.removeAllOverlays();mapObj.setCurrentMouseTool(DRAW_CIRCLE);" class="btnbg" style="width:70px;" value="画圆查询"/><input type="button" onclick="mapObj.removeAllOverlays();mapObj.setCurrentMouseTool(DRAW_RECTANGLE);" value="矩形查询" class="btnbg" style="width:70px;"/><input type="button" onclick="mapObj.removeAllOverlays();mapObj.setCurrentMouseTool(DRAW_POLYGON);" value="多边形查询" class="btnbg" style="width:70px;"/></div></br><div id="count_look"  sytle="overflow:scroll;"></div>';
	showMapMenu("区域分析",str);
	}
var regionId="";
function addOverlayEvent(param){
	var keywords = document.getElementById("keyword").value;
	var MSearch = new MPoiSearch();
	var opt = new MPoiSearchOptions();
	opt.recordsPerPage = 50;//每页返回数据量，默认为10
	opt.pageNum = 1;//当前页数。
	opt.dataType = "";//数据类别，该处为分词查询，只需要相关行业关键字即可
	opt.dataSources = DS_BASE_ENPOI;//数据源，基础+企业地标数据库（默认）
	MSearch.setCallbackFunction(searchSearchresult_CallBack);
	var overlay=mapObj.getOverlayById(param.overlayId);
	switch(overlay.TYPE){
		case "Polygon":
			mapObj.removeOverlayById(regionId);
			regionId=param.overlayId;
			MSearch.poiSearchByRegion(MOverlay.TYPE_POLYGON,new MLngLats(overlay.lnglatArr),keywords,opt);
		break;
		case "Rectangle":
			mapObj.removeOverlayById(regionId);
			regionId=param.overlayId;
			MSearch.poiSearchByRegion(MOverlay.TYPE_RECTANGLE,new MLngLats(overlay.lnglatArr),keywords,opt);
		break;
		case "Circle":
			mapObj.removeOverlayById(regionId);
			var region = overlay.bounds.southWest.lngX+","+overlay.bounds.northEast.latY+","+overlay.bounds.northEast.lngX+","+overlay.bounds.southWest.latY;
			var arr1 = region.split(",");
			var regionArr=new Array();
			for(var i = 0 ;i<=arr1.length-2;){
					var mll =new MLngLat(arr1[i],arr1[i+1]);
					regionArr.push(mll);
					i=i+2;
			}
			regionId=param.overlayId;
			MSearch.poiSearchByRegion(MOverlay.TYPE_CIRCLE,new MLngLats(regionArr),keywords,opt);
		break;
		default:
		break;
	}
}
var resultCount=10;
function searchSearchresult_CallBack(data){
	mapObj.setCurrentMouseTool(PAN_WHEELZOOM);
	var resultStr="";
	if(data.error_message != null){
		resultStr="查询异常！"+data.error_message;
	}else{
	switch(data.message){
		case 'ok':
			var marker = new Array();
			if(data.searchresult.record==0){
				resultStr = "未查找到任何结果!<br />建议：<br />1.请确保所有字词拼写正确。<br />2.尝试不同的关键字。<br />3.尝试更宽泛的关键字。";
			}else{
				resultCount=data.searchresult.list.length;
				for (var i = 0; i < data.searchresult.list.length; i++) {
					resultStr += "<div id='divid"+(i)+"' onclick=\"javascript:var s=mapObj.setCenter(new MLngLat('"+ data.searchresult.list[i].x +"','"+ data.searchresult.list[i].y +"'));var t = mapObj.openOverlayTip('"+(i)+"');\" style=\"font-size: 13px;cursor:pointer;padding:2px 0 10px 5px;\">"+(i+1)+"、"+data.searchresult.list[i].name+"<br/>";

					resultStr += TipContents(data.searchresult.list[i].type,data.searchresult.list[i].address,data.searchresult.list[i].tel);
					resultStr += "<br />城市："+data.searchresult.list[i].citycode + "<br \/></div>";

					var markerOption = new MMarkerOptions();
					markerOption.imageUrl ="http://code.mapabc.com/images/lan_1.png";

					var tipOption = new MTipOptions();
					tipOption.title=(i+1) + ". "+ data.searchresult.list[i].name;
					var tipC = "<br />"+TipContents(data.searchresult.list[i].type,data.searchresult.list[i].address,data.searchresult.list[i].tel)
					tipOption.content=tipC;//tip内容
					tipOption.borderStyle.thickness=2;
					tipOption.borderStyle.color= 0x005cb5;
					tipOption.borderStyle.alpha=1;
					tipOption.titleFontStyle.name="Arial";
					tipOption.titleFontStyle.size=12;
					tipOption.titleFontStyle.color= 0xffffff;
					tipOption.titleFontStyle.bold=true;
					tipOption.contentFontStyle.name="Arial";
					tipOption.contentFontStyle.size=13;
					tipOption.contentFontStyle.color= 0x000000 ;
					tipOption.contentFontStyle.bold=false;
					tipOption.fillStyle.color= 0xFFFFFF; //填充色
					tipOption.fillStyle.alpha=1;
					tipOption.titleFillStyle.color=0x005cb5;
					tipOption.titleFillStyle.alpha=1;

					markerOption.tipOption = tipOption;
					markerOption.canShowTip=true;
					var mar = new MMarker(new MLngLat(data.searchresult.list[i].x,data.searchresult.list[i].y),markerOption);
					mar.id=(i);
					marker.push(mar);
				}
				mapObj.addOverlays(marker,true);
				mapObj.addEventListener(mapObj,TIP_OPEN,openTip);
			}
		break;
		case 'error':
			resultStr= "<div class=\"default\"><div class=\"default_title\">网络忙！请重新尝试！</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建议：</strong><br />如果您刷新页后仍无法显示结果，请过几分钟后再次尝试或者与我们的服务人员联系。<br />Email：service@mapabc.com <br />电话：400 810 0080</div></div></span>错误信息："+data.message+"</div>";
		break;
		default:
			resultStr= "<div class=\"default\"><div class=\"default_title\">对不起！网络繁忙！请稍后重新尝试！</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建议：</strong><br />如果您刷新页后仍无法显示结果，请过几分钟后再次尝试或者与我们的服务人员联系。<br />Email：service@mapabc.com <br />电话：400 810 0080</div></div></span>错误信息："+data.message+"</div>";
		}
	}
	document.getElementById("count_look").style.height="250px";
	document.getElementById("count_look").innerHTML = resultStr;
}
function TipContents(type,address,tel){
	if (type == "" || type == "undefined" || type == null || type == " undefined" || typeof type == "undefined") {
		type = "暂无";
	}
	if (address == "" || address == "undefined" || address == null || address == " undefined" || typeof address == "undefined") {
		address = "暂无";
	}
	if (tel == "" || tel == "undefined" || tel == null || tel == " undefined" || typeof address == "tel") {
		tel = "暂无";
	}
	var str ="地址：" + address + "<br>电话：" + tel + " <br>类型："+type;
	return str;
}
function openMarkerTipById1(pointid,thiss){  //根据id打开搜索结果点tip
	thiss.style.background='#CFD6E8';
	//mapObj.openOverlayTip(pointid);
}
function onmouseout_MarkerStyle(pointid,thiss) {//鼠标移开后点样式恢复
   thiss.style.background="";
}
function openTip(param){
	var n = "divid"+(param.overlayId);
	for (var i = 0; i < resultCount; ++i){
		var id="divid"+i;
		document.getElementById(id).style.background='';
		document.getElementById(id).onmouseout = function(){this.style.backgroundColor='';};
	}
	document.getElementById(n).style.background='#CFD6E8';
	document.getElementById(n).onmouseout = function(){this.style.backgroundColor='#CFD6E8';};
}











/*---------------------------------------------------------------考勤管理-----------------------------------------------------------------------------*/

function check_work(){
var str='<div style="text-align:center">请选择区域:<select id="epersonal1" ></select><input type="button" class="btnbg" value="显示" onclick="look()" /><input type="button" class="btnbg" value="考勤" onclick="Query_man()" /></br>时间：<input id="StartTime" type="text" name="StartTime" class="Wdate" onfocus="WdatePicker()" style="width:184px" /><br/><div id="save"></div><div id="save_is"></div>';
	showMapMenu("考勤统计",str);
	$.ajax({
			type:"POST",
			url:"public/ManageMap/itemList.php",
			cache:false,
			data:"option=bound",
			success:function(data){
				if(data!="N"){
					var arr=data.split("_");
				var arr1=new Array();
				for(var i=0;i<arr.length-1;++i){
					arr1[i]=[arr[i].split(";")[0],arr[i].split(";")[1]];
					}
				document.getElementById('epersonal1').innerHTML="";
				AddSelectOption(arr1,"epersonal1");
					}
				else{
					document.getElementById('save_is').innerHTML="<font style='color:#F00'>没有区域信息...</font>";
					}
				}
		});
	function AddSelectOption(array, selectid){
		if(array){
			for(var i=0;i<array.length;++i){
				var oOption = document.createElement('OPTION');
				oOption.text = array[i][1];
				oOption.value = array[i][0];
				document.getElementById(selectid).options.add(oOption); }}}}
				
function look(){
	var a=document.getElementById('epersonal1').value;
	$.ajax({
			type:"POST",
			async:false,
			url:"public/ManageMap/itemList.php",
			cache:false,
			data:"boundid="+a,
			success:function(data){
				if(data!="N"){	
				mapObj.removeAllOverlays();
				var arrpolygon = new Array();
			for(var i=0;i<data.split(';').length-1;++i){
				arrpolygon.push(new MLngLat(data.split(';')[i].split(',')[0],data.split(';')[i].split(',')[1]));
				}
	var areaopt = new MAreaOptions();
	var polygon = new MPolygon(arrpolygon,areaopt);
	mapObj.addOverlay(polygon,true);
					}else{
					document.getElementById('save_is').innerHTML="<font style='color:#F00'>没该有区域信息</font>";}}});}
					
					
					
function Query_man(){
	document.getElementById('save').innerHTML="";
	$("#save").css('overflow-y','scroll');
	$("#save").css('height','200px');
	var StartTime = document.getElementById('StartTime').value;
	if(StartTime == ''){
		alert('请选择时间');
		return false;
	}
		var sd = new Date(StartTime.replace(/-/g,"\/"));
		if(sd>new Date()){
		alert('您输入的时间大于当前时间');
		return false;
			}
	 mapObj.removeAllOverlays();
		look();
		var arr=mapObj.getOverlaysByType(MOverlay.TYPE_POLYGON);
	if(arr.length==0){
		return ;
	}
	var regionXY=new Array(); 
	for(var j=0;j<arr[arr.length-1].lnglatArr.length;j++){
		regionXY.push({lon:arr[arr.length-1].lnglatArr[j].lngX,lat:arr[arr.length-1].lnglatArr[j].latY});
	}
	$.ajax({
			type:"POST",
			async:false,
			url:"public/ManageMap/itemList.php",
			cache:false,
			data:"rect=1&ts="+StartTime+"&t="+document.getElementById('epersonal1').value,
			success:function(data){
				var allarr=eval(data);
				var n=0;
				var str="车牌号";
				if(allarr.length<2){
					document.getElementById('save').innerHTML+="<font style='color:#F00'>这个区域没有选择考勤车辆和人员...</font>";
					return 0;
					}
				for(var i=0;i<allarr.length;++i){
					for(var key in allarr[i][0]){
						if (key=='a')str="人员号";
						else ceshi(str,key,allarr[i][0][key]);
						}
					}
				}
				});	
function ceshi(obj,key,objarr){
	var c=0;
	if(objarr.length==0){
		if(obj=='车牌号'){
		document.getElementById('save').innerHTML+="<font style='color:#F00'>车牌号："+key+"于：选择日期没有出现在考勤范围</font></br>";
			}else{
				document.getElementById('save').innerHTML+="<font style='color:#F00'>人员号："+key+"于：选择日期没有出现在考勤范围</font></br>";
				}
		return 0;}
	var resultStr="";
	var point={lon:0,lat:0};
	var z=null;
	var lonlatarr=[];
	var arr=new Array();
	var arrc=new Array();
	for(var n=0;n<objarr.length;++n){lonlatarr.push([objarr[n].LONGITUDE,objarr[n].LATITUDE]);}lonlatarr=gpsToMaps(lonlatarr.join(";"));
		if(lonlatarr.length==0){
		return 0;
		}
    for(var n1=0;n1<objarr.length;++n1){objarr[n1].LONGITUDE=lonlatarr[n1][0];objarr[n1].LATITUDE=lonlatarr[n1][1];}
	
	if(obj=="车牌号"){
		arr=[];
		for(var i=0;i<objarr.length;++i){
		arr.push(new MLngLat(objarr[i].LONGITUDE,objarr[i].LATITUDE));
		}
		arrc=[];
		arrc.push(objarr[0].LONGITUDE);
		arrc.push(objarr[0].LATITUDE);
		addMarker("开始",'images/satrt.gif',arrc);
		addMPolyline(obj+":"+key,arr);
		arrc=[];
		arrc.push(objarr[objarr.length-1].LONGITUDE);
		arrc.push(objarr[objarr.length-1].LATITUDE);
		addMarker("结束",'images/jiantou.png',arrc);
		point.lon=objarr[0].LONGITUDE;
		point.lat=objarr[0].LATITUDE;
		if(abc(point,regionXY)){z=1;
		++c;
		}else{z=2;}
		for(var i=0;i<objarr.length;++i){
		point.lon=objarr[i].LONGITUDE;
		point.lat=objarr[i].LATITUDE;
		if(abc(point,regionXY)){
			++c;
			if(z!=1){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("进入",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
			 resultStr+="车牌："+key+"于："+objarr[i].RECV_TIME+"进考勤范围</br>";}z=1;}
		     if(!abc(point,regionXY)){	 
				if(z!=2){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("出去",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
					resultStr +="车牌："+key+"于："+objarr[i].RECV_TIME+"出考勤范围</br>";
					}
				z=2;
				}
		}
		}else{
		arr=[];
		for(var i=0;i<objarr.length;++i){
		arr.push(new MLngLat(objarr[i].LONGITUDE,objarr[i].LATITUDE));
		}
		arrc=[];
		arrc.push(objarr[0].LONGITUDE);
		arrc.push(objarr[0].LATITUDE);
		addMarker("开始",'images/satrt.gif',arrc);
		addMPolyline(obj+":"+key,arr);
		arrc=[];
		arrc.push(objarr[objarr.length-1].LONGITUDE);
		arrc.push(objarr[objarr.length-1].LATITUDE);
		addMarker("结束",'images/jiantou.png',arrc);	
		point.lon=objarr[0].LONGITUDE;
		point.lat=objarr[0].LATITUDE;
		if(abc(point,regionXY)){z=1;++c;}else{z=2;}
		for(var i=0;i<objarr.length;++i){
		point.lon=objarr[i].LONGITUDE;
		point.lat=objarr[i].LATITUDE;
		if(abc(point,regionXY)){
			++c;
			if(z!=1){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("进入",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
			 resultStr+="人员："+key+"于："+objarr[i].RECV_TIME+"进考勤范围</br>";
					}
				z=1;
				}
		     if(!abc(point,regionXY)){
				if(z!=2){
				
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("出去",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
					resultStr +="人员:"+key+"于："+objarr[i].RECV_TIME+"出考勤范围</br>";
					}
				z=2;
				}
		}
		}
	if(c==0){
		if(obj=='车牌号'){
		document.getElementById('save').innerHTML+="<font style='color:#F00'>车牌："+key+"于：选择日期没有出现在考勤范围</font></br>";
			}else{
				document.getElementById('save').innerHTML+="<font style='color:#F00'>人员："+key+"于：选择日期没有出现在考勤范围</font></br>";
				}
		return 0;}
	document.getElementById('save').innerHTML+=resultStr;
	}
function addMPolyline(str,arr){
	var tipOption=new MTipOptions();
    tipOption.title="车辆信息";
    tipOption.content=str;
	var lineopt=new MLineOptions();
	lineopt.tipOption=tipOption;
	lineopt.canShowTip=true;
	var polyline=new MPolyline(arr,lineopt);
	mapObj.addOverlay(polyline,true);
}
function addMarker(a,b,c){
  var labelOption=new MLabelOptions();
  labelOption.content=a;
  labelOption.hasBorder=true;
  labelOption.hasBackground=true;
  labelOption.labelPosition=new MPoint(10,10);
  var markerOption = new MMarkerOptions();
  markerOption.imageUrl=b;
  markerOption.anchor=new MPoint(0,0);
  markerOption.imageAlign=BOTTOM_CENTER;
  markerOption.labelOption=labelOption;
  markerOption.isEditable=false;
  Mmarker = new MMarker(new MLngLat(c[0],c[1]),markerOption);
  mapObj.addOverlay(Mmarker,true) ;
}
	}
	
	
	
/*===============================================================================================================*/	
	
	
function area_count(){
	var str='<div style="text-align:center"><input type="button" class="btnbg" value="画出统计区域范围" onclick="add_p()" /></div><div id="save"></div><div id="save_is"></div>';
showMapMenu('区域统计',str);
	}
function add_p(){
	mapObj.addEventListener(mapObj,ADD_OVERLAY,mouseDrawPolygonMulti_1);
	mapObj.setCurrentMouseTool(DRAW_POLYGON);}
function mouseDrawPolygonMulti_1(){
	var regionXY=new Array();
	mapObj.setCurrentMouseTool(PAN_WHEELZOOM);
	var arr=mapObj.getOverlaysByType(MOverlay.TYPE_POLYGON);
	if(arr.length==0){
		return ;
	}
	for(var j=0;j<arr[arr.length-1].lnglatArr.length;j++){
		regionXY.push(arr[arr.length-1].lnglatArr[j].lngX+","+arr[arr.length-1].lnglatArr[j].latY+";");
	}
	var str="";
	var str_1="";
	for(var i=0;i<regionXY.length;++i){
		str_1+=regionXY[i];
	str+=regionXY[i]+"</br>";}
	document.getElementById('save_is').innerHTML='';
	mapObj.removeEventListener(mapObj,ADD_OVERLAY,mouseDrawPolygonMulti_1);
	document.getElementById('save').innerHTML='开始时间：<input id="StartTime" type="text" name="StartTime" class="Wdate" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\'})" style="width:184px" /></br>结束时间：<input type="text" id="EndTime" name="EndTime" class="Wdate" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\'})" style="width:184px" /><br/>';
	document.getElementById('save').innerHTML+='负责单位：';
	document.getElementById('save').innerHTML+='<select id="edepartment"  multiple="multiple"  size="4" style="width:140px" datatype=\'select\'   onblur="SelectedDep(this)" ></select></br>';
	document.getElementById('save').innerHTML+='选择人员：';
	document.getElementById('save').innerHTML+='<select id="epersonal"  multiple="multiple"  disabled="false"><option value="">请先选择单位</option></select></br>';
	document.getElementById('save').innerHTML+='选择车辆：<select id="evehicle"  multiple="multiple"  disabled="false"><option value="">请先选择单位</option></select></br>';
	document.getElementById('save').innerHTML+='<input type="button" onclick="saverect()"  class="btnbg"  value="查询" />';
			$.ajax({
			type:"POST",
			url:"public/ManageMap/itemList.php",
			cache:false,
			data:"option=me",
			success:function(data){
				var arr=data.split("_");
				var arr1=new Array();
				for(var i=0;i<arr.length-1;++i){
					arr1[i]=[arr[i].split(";")[0],arr[i].split(";")[1]];
					}
				document.getElementById('edepartment').innerHTML="";
				AddSelectOption(arr1,"edepartment");
		function AddSelectOption(array, selectid){
		if(array){
			for( var i=0;i<array.length;++i){
				var oOption = document.createElement('OPTION');
				oOption.text = array[i][1];
				oOption.value = array[i][0];
				document.getElementById(selectid).options.add(oOption); 

			}
		}
}
				}
		});	
	}
function SelectedDep(obj){
	var SelectedDepartmendID = [];
	var dep =obj.options;
	for(var i=0; i<dep.length;i++){
		if(dep[i].selected == true){
			SelectedDepartmendID.push(dep[i].value);
		}
	}
	if(SelectedDepartmendID.length==0){
		document.getElementById('save_is').innerHTML="<font style='color:#F00'>没有选择判处所...</font>";
		return 0;
		}
	$.ajax({
		type:'POST',
		url:'manageAnjian.php',
		async:false,
		data:'act=select&selectedID='+SelectedDepartmendID,
		success:function(data){
			var arr = data.split('|');
		  if(arr[0] !== ''){
				$('#epersonal').html('');
				$('#epersonal').attr('size','4');
				$('#epersonal').attr('multiple','multiple');
				$('#epersonal').attr('disabled','');
				$('#epersonal').html(arr[0]);
			}else{
				$('#epersonal').attr('size','1');
				$('#epersonal').attr('multiple','');
				$('#epersonal').attr('disabled','false');
				$('#epersonal').html('<option value="">请先选择单位</option>');
			}
			//添加车辆
			if(arr[1] !== ''){
				$('#evehicle').html('');
				$('#evehicle').attr('size','4');
				$('#evehicle').attr('multiple','multiple');
				$('#evehicle').attr('disabled','');
				$('#evehicle').html(arr[1]);
				document.getElementById('save_is').innerHTML="";
			}else{
				$('#evehicle').attr('size','1');
				$('#evehicle').attr('multiple','');
				$('#evehicle').attr('disabled','false');
				$('#evehicle').html('<option value="">请先选择单位</option>');
				document.getElementById('save_is').innerHTML+="";
			}
			if(arr[0]==''&&arr[1]== ''){
		document.getElementById('save_is').innerHTML="<font style='color:#F00'>你选择单位没数据...</font>";
				}
		}
	});
}
function saverect(){
  var StartTime = $('#StartTime').attr("value");
	var EndTime   = $('#EndTime').attr("value");
	if(StartTime == ''){
		document.getElementById('save_is').innerHTML="<font style='color:#F00'>请选择开始时间...</font>";
		return false;
	}else if(EndTime == ''){
		document.getElementById('save_is').innerHTML="<font style='color:#F00'>请选择结束时间...</font>";
		return false;
	}else{
		var sd = new Date(StartTime.replace(/-/g,"\/"));
		var ed = new Date(EndTime.replace(/-/g,"\/"));
		if(sd>=ed){
		document.getElementById('save_is').innerHTML="<font style='color:#F00'>开始时间大于或者等于结束时间...</font>";
			return false;
		}
	}
	var obj_str="";
	var obj_str1="";
	var obj=document.getElementById('epersonal').options;
	var obj1=document.getElementById('evehicle').options;
	var n=0;
	for(var i=0;i<obj.length;++i){
		if(obj[i].selected==true){
			obj_str+=obj[i].value+",";
			++n;
			}
		}	
	for(var i=0;i<obj1.length;++i){
		if(obj1[i].selected ==true){
			obj_str1+=obj1[i].value+",";
			++n;
			}
		}
		
if(n==0){
	document.getElementById('save_is').innerHTML="<font style='color:#F00'>没有选中人员或者车辆信息...</font>";
	return 0;
	}	
var arr=mapObj.getOverlaysByType(MOverlay.TYPE_POLYGON);
	if(arr.length==0){
		return ;
	}
	var regionXY=new Array(); 
	for(var j=0;j<arr[arr.length-1].lnglatArr.length;j++){
		regionXY.push({lon:arr[arr.length-1].lnglatArr[j].lngX,lat:arr[arr.length-1].lnglatArr[j].latY});
	}
$.ajax({
			type:"POST",
			url:"public/ManageMap/itemList.php",
			cache:false,
			data:"option=area&a="+obj_str1.substr(0,obj_str1.length-1)+"&b="+obj_str.substr(0,obj_str.length-1)+"&ts="+StartTime+"&te="+EndTime,
			success:function(data){
				var allarr=eval(data);
				var str="车牌号";
				document.getElementById('save_is').innerHTML="";
				$("#save_is").css('overflow-y','scroll');
				$("#save_is").css('height','70px');
				for(var i=0;i<allarr.length;++i){
					for(var key in allarr[i][0]){
						if (key=='a')str="人员号";
						else ceshi(str,key,allarr[i][0][key]);
						}
					}
				}
		});
		
	function ceshi(obj,key,objarr){
	var c=0;
	if(objarr.length==0){
		if(obj=='车牌号'){
		document.getElementById('save_is').innerHTML+="<font style='color:#F00'>车牌号："+key+"于：选择日期没有出现该区域</font></br>";
			}else{
				document.getElementById('save_is').innerHTML+="<font style='color:#F00'>人员号："+key+"于：选择日期没有出现该区域</font></br>";
				}
		return 0;}
	var resultStr="";
	var point={lon:0,lat:0};
	var z=null;
	var lonlatarr=[];
	var arr=new Array();
	var arrc=new Array();
	for(var n=0;n<objarr.length;++n){lonlatarr.push([objarr[n].LONGITUDE,objarr[n].LATITUDE]);}lonlatarr=gpsToMaps(lonlatarr.join(";"));
	if(lonlatarr.length==0){
		return 0;
		}
    for(var n1=0;n1<objarr.length;++n1){objarr[n1].LONGITUDE=lonlatarr[n1][0];objarr[n1].LATITUDE=lonlatarr[n1][1];}
	
	if(obj=="车牌号"){
		arr=[];
		for(var i=0;i<objarr.length;++i){
		arr.push(new MLngLat(objarr[i].LONGITUDE,objarr[i].LATITUDE));
		}
		arrc=[];
		arrc.push(objarr[0].LONGITUDE);
		arrc.push(objarr[0].LATITUDE);
		addMarker("开始",'images/satrt.gif',arrc);
		addMPolyline(obj+":"+key,arr);
		arrc=[];
		arrc.push(objarr[objarr.length-1].LONGITUDE);
		arrc.push(objarr[objarr.length-1].LATITUDE);
		addMarker("结束",'images/jiantou.png',arrc);
		point.lon=objarr[0].LONGITUDE;
		point.lat=objarr[0].LATITUDE;
		if(abc(point,regionXY)){z=1;
		++c;
		}else{z=2;}
		for(var i=0;i<objarr.length;++i){
		point.lon=objarr[i].LONGITUDE;
		point.lat=objarr[i].LATITUDE;
		if(abc(point,regionXY)){
			++c;
			if(z!=1){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("进入",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
			 resultStr+="车牌："+key+"于："+objarr[i].RECV_TIME+"进区域</br>";}z=1;}
		     if(!abc(point,regionXY)){	 
				if(z!=2){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("出去",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
					resultStr +="车牌："+key+"于："+objarr[i].RECV_TIME+"出区域</br>";
					}
				z=2;
				}
		}
		}else{
		arr=[];
		for(var i=0;i<objarr.length;++i){
		arr.push(new MLngLat(objarr[i].LONGITUDE,objarr[i].LATITUDE));
		}
		arrc=[];
		arrc.push(objarr[0].LONGITUDE);
		arrc.push(objarr[0].LATITUDE);
		addMarker("开始",'images/satrt.gif',arrc);
		addMPolyline(obj+":"+key,arr);
		arrc=[];
		arrc.push(objarr[objarr.length-1].LONGITUDE);
		arrc.push(objarr[objarr.length-1].LATITUDE);
		addMarker("结束",'images/jiantou.png',arrc);	
		point.lon=objarr[0].LONGITUDE;
		point.lat=objarr[0].LATITUDE;
		if(abc(point,regionXY)){z=1;++c;}else{z=2;}
		for(var i=0;i<objarr.length;++i){
		point.lon=objarr[i].LONGITUDE;
		point.lat=objarr[i].LATITUDE;
		if(abc(point,regionXY)){
			++c;
			if(z!=1){
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("进入",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
			 resultStr+="人员："+key+"于："+objarr[i].RECV_TIME+"进区域</br>";
					}
				z=1;
				}
		     if(!abc(point,regionXY)){
				if(z!=2){
				
		    arrc=[]
			arrc.push(objarr[0].LONGITUDE);
		    arrc.push(objarr[0].LATITUDE);
			 addMarker("出去",'http://api.mapabc.com/ajaxmap/2.1.2/js/img/lan_1.png',arrc);
					resultStr +="人员:"+key+"于："+objarr[i].RECV_TIME+"出区域</br>";
					}
				z=2;
				}
		}
		}
	if(c==0){
		if(obj=='车牌号'){
		document.getElementById('save_is').innerHTML+="<font style='color:#F00'>车牌："+key+"于：选择日期没有出现该区域</font></br>";
			}else{
				document.getElementById('save_is').innerHTML+="<font style='color:#F00'>人员："+key+"于：选择日期没有出现该区域</font></br>";
				}
		return 0;}
	document.getElementById('save_is').innerHTML+=resultStr;
	}
function addMPolyline(str,arr){
	var tipOption=new MTipOptions();
    tipOption.title="车辆信息";
    tipOption.content=str;
	var lineopt=new MLineOptions();
	lineopt.tipOption=tipOption;
	lineopt.canShowTip=true;
	var polyline=new MPolyline(arr,lineopt);
	mapObj.addOverlay(polyline,true);
}
function addMarker(a,b,c){
  var labelOption=new MLabelOptions();
  labelOption.content=a;
  labelOption.hasBorder=true;
  labelOption.hasBackground=true;
  labelOption.labelPosition=new MPoint(10,10);
  var markerOption = new MMarkerOptions();
  markerOption.imageUrl=b;
  markerOption.anchor=new MPoint(0,0);
  markerOption.imageAlign=BOTTOM_CENTER;
  markerOption.labelOption=labelOption;
  markerOption.isEditable=false;
  Mmarker = new MMarker(new MLngLat(c[0],c[1]),markerOption);
  mapObj.addOverlay(Mmarker,true) ;
}
	}
	
	
function abc(point,arr){
	var c=0;
	var a,a1,b,b1;
	for(var i=0;i<arr.length;++i){
		if(i==arr.length-1){
			a=arr[i].lon>arr[0].lon?arr[i].lon:arr[0].lon; 
		if(a==arr[i].lon){
			a1=arr[0].lon;}else{
				a1=arr[i].lon;
				}
	    b=arr[i].lat>arr[0].lat?arr[i].lat:arr[0].lat; 
		if(b==arr[i].lat){
			b1=arr[0].lat;}else{
				b1=arr[i].lat;
				}
		if(((b1<=point.lat&&b>=point.lat)&&(a-(point.lat-b1)/(b-b1)*(a-a1)>point.lon))){
			++c;
			}
}else{
		a=arr[i].lon>arr[i+1].lon?arr[i].lon:arr[i+1].lon; 
		if(a==arr[i].lon){
			a1=arr[i+1].lon;}else{
				a1=arr[i].lon;
				}
	    b=arr[i].lat>arr[i+1].lat?arr[i].lat:arr[i+1].lat; 
		if(b==arr[i].lat){
			b1=arr[i+1].lat;}else{
				b1=arr[i].lat;
				}
		if(((b1<=point.lat&&b>=point.lat)&&(a-(point.lat-b1)/(b-b1)*(a-a1)>point.lon))){
			++c;
			}
		}
		}
	if(c%2==0){
		return false;
		}else{
			return true;
			}
	}
	
	
function abc1(point,arr){
	var c=false;var a,a1,b,b1;
	for(var i=0;i<arr.length;++i){
		if(i==arr.length-1){
		a=arr[i].lon>arr[0].lon?arr[i].lon:arr[0].lon; if(a==arr[i].lon){a1=arr[0].lon;}else{a1=arr[i].lon;}
	    b=arr[i].lat>arr[0].lat?arr[i].lat:arr[0].lat; if(b==arr[i].lat){b1=arr[0].lat;}else{b1=arr[i].lat;}
		
}else{
	  a=arr[i].lon>arr[i+1].lon?arr[i].lon:arr[i+1].lon; if(a==arr[i].lon){a1=arr[i+1].lon;}else{a1=arr[i].lon;}
	  b=arr[i].lat>arr[i+1].lat?arr[i].lat:arr[i+1].lat; if(b==arr[i].lat){b1=arr[i+1].lat;}else{b1=arr[i].lat;}
				
		}
		}
      return c;
	}